//-------------------------------------------------------------------------------------
//buyproperties
function buyproperties()
	{
	if (location.href.indexOf(SCRIPT.name+'/properties') != -1)
		{
		var crewPropertyRowPath = "//form[@id='app16421175101_properties_viral_purchase']";
		var crewPropertyRow = xpathFirst(crewPropertyRowPath);
			
		var allPropertyRowsPath = "//form[@id='app16421175101_properties_purchase']";
		var allPropertyRows = xpath(allPropertyRowsPath);
		
		var property2RowsPath = "//form[@id='app16421175101_properties_purchase2']";
		var property2Rows = xpath(property2RowsPath);
//		bestProperty = eval(GM_getValue('bestProperty',''));
		var index = parseInt(bestProperty.id);
		if (index == 0)
			{
			var sForm = crewPropertyRow.parentNode.parentNode.parentNode.parentNode.getElementsByTagName('form')[0];
			}
		else if (index < 5)
			{
			index = index - 1;
			var sForm = allPropertyRows.snapshotItem(index).parentNode.parentNode.parentNode.getElementsByTagName('form')[0];
			sForm.getElementsByTagName('select')[0].value = 10;
			}
		else if (index < 13)
			{
			index = index - 6;
			var sForm = property2Rows.snapshotItem(index).parentNode.parentNode.parentNode.getElementsByTagName('form')[0];
			sForm.getElementsByTagName('select')[0].value = 10;
			}
		sForm.submit();
		}
	else
		{
		window.location = "http://apps.facebook.com/"+SCRIPT.name+"/properties.php";
		flag = 1;
		}
	}
